package com.simple.simple_view.controller.video;

import com.simple.simple_view.domain.ResponseResult;
import com.simple.simple_view.domain.dto.FavoriteDto;
import com.simple.simple_view.domain.enums.AppHttpCodeEnum;
import com.simple.simple_view.exception.SystemException;
import com.simple.simple_view.service.UserLikeVideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/*
 *@description: 点赞接口
 *@author: hisen
 *@Time: 2023/10/28  19:48
 */
@RestController
@RequestMapping("/video")
@Slf4j
public class FavoriteController {
    @Resource
    UserLikeVideoService userLikeVideoService;
    @PostMapping("/favorite")
    public ResponseResult like(@RequestBody FavoriteDto favoriteDto){
        if(favoriteDto.getUserId()==null){
            throw new SystemException(AppHttpCodeEnum.USER_ID_NOT_NULL);
        }
        if(favoriteDto.getVideoId()==null){
            throw new SystemException(AppHttpCodeEnum.VIDEO_ID_NOT_NULL);
        }
        if(favoriteDto.getIsLike()==null){
            throw new SystemException(AppHttpCodeEnum.LIKE_OPERATION_NOT_NULL);
        }
        if(favoriteDto.getByUserId()==null){
            throw new SystemException(AppHttpCodeEnum.BY_USER_ID_NOT_NULL);
        }
        return userLikeVideoService.like(favoriteDto);
    }
}
